package ooday03.Demo.practice01;

public class RefArrayDemo {
    public static void main(String[] args) {
        Dog[] dogs=new Dog[3];
        dogs[0]=new Dog("小黄",2,"红");
        dogs[1]=new Dog("小红",1,"黑");
        dogs[2]=new Dog("小蓝",1,"蓝");
        dogs[1].age=4;
        dogs[2].swim();
        for(int i=0;i<dogs.length;i++){
            System.out.println(dogs[i].name);
            dogs[i].eat();
        }
        System.out.println();
        Chick[] chicks=new Chick[2];
        chicks[0]=new Chick("小黄",1,"黄");
        chicks[1]=new Chick("小黑",1,"黑");
        for (int i=0;i<chicks.length;i++){
            System.out.println(chicks[i].name);
            chicks[i].eat();
        }
        System.out.println();
        Fish[] fishs=new Fish[2];
        fishs[0]=new Fish("小黑",1,"黄");
        fishs[1]=new Fish("小黄",1,"黑");
        for (int i=0;i<fishs.length;i++){
            System.out.println(fishs[i].name);
            fishs[i].eat();
        }
    }
}
